package com.spsoft.vatoutinv.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.vatoutinv.model.dto.vmsepsInformation.VmsEpsCheckDto;
import com.spsoft.vatoutinv.model.dto.vmsepsInformation.VmsEpsClassifyCodePageDto;
import com.spsoft.vatoutinv.model.dto.vmsepsInformation.VmsEpsInformationDto;
import com.spsoft.vatoutinv.model.dto.vmsepsInformation.VmsEpsInformationQueryDto;
import com.spsoft.vatoutinv.model.vo.vmsclassifycode.VmsClassifyCodeForEpsPageVOList;
import com.spsoft.vatoutinv.model.vo.vmsclassifycode.VmsClassifyCodePageVOList;
import com.spsoft.vatoutinv.model.vo.vmsepsInformation.VmsEpsInformationVo;
import com.spsoft.vatoutinv.model.vo.vmsepsInformation.VmsEpsUpdateInformationVo;
import com.spsoft.vatoutinv.service.vmsepsInformation.VmsEpsInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author liwm
 * @Desc 企业商品及服务信息管理表;企业商品及服务信息管理表 SEQ_VMS_EPS_INFORMATION
Enterprise Product and Service Information Management(VmsEpsInformation)表控制层
 * @Date 2024-01-08 13:24:30
 */
@Api(tags = "企业商品及服务信息管理页签")
@RestController
@RequestMapping("/vmsEpsInformation")
@RequiredArgsConstructor
@Validated
@Slf4j
public class VmsEpsInformationController {

    public static final String LOG_MSG = "(企业商品及服务信息管理控制层)";

    private final VmsEpsInformationService vmsEpsInformationService;

    @ApiOperation("企业商品及服务信息查询接口")
    @AnonymousAccess(value = "/query", method = RequestMethod.POST, permissionCode = "VMS_QYSPJFFXXGL")
	@Log(value = "企业商品及服务信息查询接口", type = LogActionType.SELECT, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result<IPage<VmsEpsInformationVo>> queryByPage(@RequestBody VmsEpsInformationQueryDto param) {
        log.info("{}企业商品及服务信息-查询接口，入参：{}", LOG_MSG, JSONObject.toJSONString(param));
        return vmsEpsInformationService.queryByPage(param);
    }

    @ApiOperation("新增接口")
    @AnonymousAccess(value = "/add", method = RequestMethod.POST, permissionCode = "VMS_FULL_EPS_ADD")
    @Log(value = "企业商品及服务信息新增接口", type = LogActionType.ADD, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result<Boolean> add(@RequestBody @Validated VmsEpsInformationDto param) {
        log.info("{}企业商品及服务信息-新增接口，入参：{}", LOG_MSG, JSONObject.toJSONString(param));
        return vmsEpsInformationService.insert(param);
    }

    @ApiOperation("更新接口")
    @AnonymousAccess(value = "/update", method = RequestMethod.POST, permissionCode = "VMS_FULL_EPS_ADD")
    @Log(value = "企业商品及服务信息更新接口", type = LogActionType.UPDATE, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result<Boolean> update(@RequestBody @Validated VmsEpsInformationDto param) {
        log.info("{}企业商品及服务信息-更新接口，入参：{}", LOG_MSG, JSONObject.toJSONString(param));
        return vmsEpsInformationService.update(param);
    }

    @ApiOperation("根据ID查询数据接口")
    @AnonymousAccess(value = "/queryById", method = RequestMethod.POST, permissionCode = "VMS_QYSPJFFXXGL")
    @Log(value = "根据ID查询数据接口", type = LogActionType.SELECT, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result<VmsEpsUpdateInformationVo> queryById(@RequestParam("id") Long id) {
        log.info("{}企业商品及服务信息-ID查询，入参：{}", LOG_MSG, id);
        return vmsEpsInformationService.queryById(id);
    }

    @ApiOperation("获取税收分类编码-分页查询")
    @AnonymousAccess(value = "/getCodePage", method = RequestMethod.POST, permissionCode = "VMS_QYSPJFFXXGL")
    @Log(value = "企业管理-获取税收分类编码-分页查询", type = LogActionType.SELECT, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result<IPage<VmsClassifyCodeForEpsPageVOList>> getCodePage(@RequestBody @Validated VmsEpsClassifyCodePageDto dto) {
        log.info("{}获取企业管理-税收分类编码-分页查询{}", LOG_MSG, JSONObject.toJSONString(dto));
        return vmsEpsInformationService.getClassCodePage(dto);
    }

    @ApiOperation("手工开票-发票项目-查询接口")
    @AnonymousAccess(value = "/queryForHandle", method = RequestMethod.POST, permissionCode = "")
    @Log(value = "手工开票-发票项目-查询接口", type = LogActionType.SELECT, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result<IPage<VmsEpsInformationVo>> queryForHandle(@RequestBody VmsEpsInformationQueryDto param) {
        log.info("{}企业商品及服务信息-查询接口，入参：{}", LOG_MSG, JSONObject.toJSONString(param));
        return vmsEpsInformationService.queryForHandleByPage(param);
    }

    @ApiOperation("验证商品服务编码接口")
    @AnonymousAccess(value = "/checkGstcmCode", method = RequestMethod.POST, permissionCode = "VMS_QYSPJFFXXGL")
    @Log(value = "根据ID查询数据接口", type = LogActionType.SELECT, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result checkGstcmCode(@RequestBody VmsEpsCheckDto param) {
        log.info("{}企业商品及服务信息-验证商品服务编码接口，入参：{}", LOG_MSG,  JSONObject.toJSONString(param));
        return vmsEpsInformationService.checkGstcmCode(param);
    }

    @ApiOperation("根据ID删除数据接口")
    @AnonymousAccess(value = "/deleteById", method = RequestMethod.POST, permissionCode = "VMS_FULL_EPS_DELETE")
    @Log(value = "根据ID删除数据接口", type = LogActionType.DELETE, menuName = LogMenuEnum.EPS_INFORMATION)
    public Result deleteById(@RequestParam("id") Long id) {
        log.info("{}企业商品及服务信息-ID查询，入参：{}", LOG_MSG, id);
        return vmsEpsInformationService.deleteById(id);
    }
}
